package modele;

public class Equation {
	//Variables de classe statiques
	public static final int INF_EQ = 0;
	public static final int SUP_EQ = 1;
	private static int NB_EQUATIONS = 0;
	
	//Variables d'instance
	private int numEq;
	private double a;
	private double b;
	private int infsup;
	private double c;
	
	/**
	 * Eq : AX + BY <= (>=) C
	 * @param a
	 * @param b
	 * @param infsup
	 * @param c
	 */
	public Equation(double a, double b, int infsup, double c) {
		this.numEq = Equation.NB_EQUATIONS+1;
		Equation.NB_EQUATIONS=this.numEq;
		this.a = a;
		this.b = b;
		this.infsup = infsup;
		this.c = c;
	}

	public double getA() {
		return a;
	}

	public void setA(double a) {
		this.a = a;
	}

	public double getB() {
		return b;
	}

	public void setB(double b) {
		this.b = b;
	}

	public double getC() {
		return c;
	}

	public void setC(int c) {
		this.c = c;
	}

	public int getInfsup() {
		return infsup;
	}

	public void setInfsup(int infsup) {
		this.infsup = infsup;
	}

	public int getNumEq() {
		return numEq;
	}


	public boolean verifierSiValide(PointIntersection pi) throws Exception {
		if (this.getInfsup()==Equation.INF_EQ) {
			return (pi.getX()*this.getA()+pi.getY()*this.getB()<=this.getC()) ;
		}
		if (this.getInfsup()==Equation.SUP_EQ) {
			return (pi.getX()*this.getA()+pi.getY()*this.getB()>=this.getC()) ;
		}
		throw new Exception ("L'equation n'est pas du type Ax+By<=C (ou >=C) :"+this.toString()) ;
	}
}
